﻿using FastEmit;

namespace FastApi
{
    public class FastModule
    {
        public FastModule(Type classType, ConstructorInvoker invoker, string routeName, bool clearFilter)
        {
            Type = classType;
            Invoker = invoker;
            RouteName = routeName;
            ClearFilter = clearFilter;
        }

        /// <summary>
        /// 类类型
        /// </summary>
        public Type Type { get; }

        /// <summary>
        /// 构造函数委托
        /// </summary>
        public ConstructorInvoker Invoker { get; }

        /// <summary>
        /// 构造函数参数类型列表
        /// </summary>
        public List<FastParam> ParamList { get; } = [];

        /// <summary>
        /// 路由名称
        /// </summary>
        public string RouteName { get; }

        /// <summary>
        /// 是否清除过滤器
        /// </summary>
        public bool ClearFilter { get; }

        /// <summary>
        /// 方法字典
        /// </summary>
        public readonly Dictionary<string, FastAction> ActionDict = [];

        /// <summary>
        /// 特性列表
        /// </summary>
        public List<object> AttributeList { get; } = [];

        /// <summary>
        /// 是否必须释放
        /// </summary>
        internal bool NeedDispose { get; set; }

        /// <summary>
        /// 是否是事务
        /// </summary>
        internal bool IsTran { get; set; }

        /// <summary>
        /// 限流个数
        /// </summary>
        public int RateLimitCount { get; internal set; }

        /// <summary>
        /// 限流key
        /// </summary>
        public string RateLimitKey { get; internal set; }

        /// <summary>
        /// 限流错误信息
        /// </summary>
        public string RateLimitMsg { get; internal set; }

        /// <summary>
        /// 限流错误码
        /// </summary>
        public int RateLimitCode { get; internal set; }

        /// <summary>
        /// swagger分组
        /// </summary>
        public string SwaggerGroup { get; internal set; }

    }
}
